<?php

/*
	info: 私有函数
*/

if (!defined('WEBINROOT'))
{
	header("HTTP/1.0 404 Not Found");
	exit();
}

if (defined('PRIVATE_FUNC'))
{
	return;
}
define('PRIVATE_FUNC', TRUE);

//数组转字符串
function ArrayToString($aryVar)
{
	if (!is_array($aryVar))
	{
		return $aryVar;
	}
	$tempStringArray = array();
	foreach ($aryVar as $tempKey => $tempValue)
	{
		if (is_bool($tempValue))
		{
			$tempValue = intval($tempValue);
		}
		elseif (is_array($tempValue))
		{
			$tempValue = '('.ArrayToString($tempValue).')';
		}
		$tempStringArray[] = "{$tempKey}:{$tempValue}";
	}
	return !empty($tempStringArray) ? implode(', ', $tempStringArray) : '';
}

//返回两个数组中前者中去掉后者一样的数据后的结果
function GetDiffAry($aryMain, $aryBase)
{
	$returnary = array();
	foreach ($aryMain as $tempkey => $tempvalue)
	{
		if (!isset($aryBase[$tempkey]))
		{
			$returnary[$tempkey] = $tempvalue;
		}
		elseif (is_array($tempvalue))
		{
			if (!is_array($aryBase[$tempkey]))
			{
				$returnary[$tempkey] = $tempvalue;
			}
			else
			{
				$tempsubdiff = GetDiffAry($tempvalue, $aryBase[$tempkey]);
				if (!empty($tempsubdiff))
				{
					$returnary[$tempkey] = $tempvalue;
				}
			}
		}
		elseif ($tempvalue != $aryBase[$tempkey])
		{
			$returnary[$tempkey] = $tempvalue;
		}
	}
	return $returnary;
}
